<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

<%try{ %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/sevde.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/prototype.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/collapse.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/util.js"></script>

        <link href="<%=request.getContextPath()%>/css/miestilo.css" rel="stylesheet" type="text/css">
        <link href="<%=request.getContextPath()%>/css/competencia.css" rel="stylesheet" type="text/css">

    </head>
    <body>

        <html:form action="evaluacionPotencial">
        	<input type="hidden" name="idEvaluado" id="idEvaluado" value='<c:out value="${formulario.strID_EMPLEADO}"/>'/>
        	<input type="hidden" name="idEvaluador" id="idEvaluador" value='<c:out value="${formulario.strID_EVALUADOR}"/>'/>
        	<input type="hidden" name="periodo" id="periodo" value='<c:out value="${formulario.strPERIODO}"/>'/>
        	<input type="hidden" name="estadoEvaluacion" id="estadoEvaluacion" value='<c:out value="${formulario.strESTADO}"/>'/>
        	
            <table class="tablaingresos" border="0">
                <tr>
                    <td align="center">
                        <table id="tb_opciones" class="tb_opciones" border="0"  >
                            <tr>
                                <td colspan="9" align="center" class="tituloJsp">
                                    Evaluaci&oacute;n Complementaria <c:out value="${formulario.strPERIODO}"/>
                                </td>
                            </tr>

                            <tr>
                                <td><IMG class='stlTdImagen' border="1" SRC='file://fs-grupos/Data_pub$/PE/RRHH/fotos_HOC/<c:out value="${formulario.strID_EMPLEADO}" />.jpg' onerror="this.src='images/sinimagen.png';" /> </td>
                                <th  rowspan="4" style="vertical-align: middle" >
                                    <table border="0" width="600px" cellpadding="2" cellspacing="2">
                                        <tr>
                                            <td  class="labelNombre" width="250px"><label>                                            
                                            <c:out value="${formulario.strNom_Empleado}" /></label></td>                                            
                                        </tr>
                                        <tr>
                                            <td  class="labelopciones"><label><c:out value="${formulario.strApellido_Empleado}" /></label> </td>
                                            <td class="espaciosEnBlanco"></td>
                                            <td>Evaluador :</td>
                                            <td class="labelopciones"><label ><c:out value="${formulario.strNom_Evaluador}" /></label> </td>
                                        </tr>
                                        <tr>
                                            <td class="labelopciones" ><label   ><c:out value="${formulario.strPuesto_Empleado}" /></label></td>
                                            <td></td>
                                            <td></td>
                                            <td class="labelopciones" ><label ><c:out value="${formulario.strPuesto_Evaluador}"  /></label> </td>
                                        </tr>
                                        <tr>
                                            <td class="labelopciones"><label ><c:out value="${formulario.strArea_Empleado}" /></label> </td>
                                        </tr>
                                    </table>
                                </th>

                                <th class="espaciosEnBlanco"></th>
                                <th rowspan="2">
                                    <table>
                                    	<c:if test="${formulario.strESTADO != 'S5'}">
	                                        <tr id="trDivGrabar">
	                                            <td>                                                
	                                                 <div id="divgrabar">
	                                                	<button class="button"  type= "button" onclick="validarPotencial('g');"> <img src="images/grabar.gif" alt=""  height="15px"/> Grabar </button>
	                                                 </div>                                              
	                                            </td>
	                                        </tr>                                        
                                           
	                                        <tr id="trDivEnviar">
	                                            <td>
	                                                <div id="divenviar">
		                                               	<button  type= "button" class="button" onclick="enviar('e');"> <img src="images/derecha.gif" alt=""  height="15px"/> Enviar</button>
	                                                </div>                                             
	                                            </td>
	                                        </tr>
										</c:if>

                                        <tr>
                                            <td>
                                                <button  type= "button" class="button" onclick="imprimirEvaluacionPotencial();"> <img src="images/icono-imprimir-mensaje.gif" alt=""  height="15px"/> Imprimir</button>
                                            </td>
                                        </tr>

                                        <tr>
                                            <td>
                                                <button  type= "button" class="button"  onclick="cerrar();"> <img src="images/cerrar.gif" alt=""  height="15px"/> Cerrar</button>
                                            </td>
                                        </tr>
                                    </table>
                                </th>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <HR>
                    </td>
                    <td>
                        <HR>
                    </td>
                </tr>
                
                <tr>
                	<td colspan="4" style="text-align: left">
                		<div id="ver_mensaje"></div>
                	</td>
                </tr>
                
                <tr>
                    <td align="center" class="tablacompetencia">
                        
                        <table id="tablaColap" cellspacing="0" cellpadding="0" class="tablesorterCompetencias" border="0">
                        	<tr>
								<th class="lblTitulos" style="width: 40%;">Dimensi&oacute;n</th>
	                            <th class="lblTitulos" style="width: 40%;"><b>Resultado</b></th>
	                            <th class="lblTitulos" style="width: 20%;"><b>Puntaje Final</b></th>
                            </tr>                            
                            
                            <c:if test="${!empty lstDimensiones}">                            	
                               <c:forEach items="${lstDimensiones}" var="dimension" varStatus="status">                               		
                               		<c:if test="${dimension.tipo == 'C'}">
                               			<c:set var="numeroPreguntas" value="${dimension.numeroFilaDetalle}" ></c:set>
                               			<c:set var="pintoPuntajeTotal" value="0"></c:set>
                               			<c:set var="puntajePorDimension" value="${dimension.puntajeFinal}"></c:set>
	                                     <tr style="height: 18px">
	                                         <td align="left" class="lblSubtitulos" colspan="3" >
	                                         	<b><c:out value="${dimension.descripcion}"/></b>
	                                         </td>
	                                     </tr>
                                     </c:if>
                                     	
                                     <c:if test="${dimension.tipo == 'D'}">                                    
	                                     <tr>
	                                         <td align="justify" style="background: #ffffff ; color: #000000" class="labelobjetivos celda">
	                                         	<div class="divDescripcion">
                                                    <c:out value="${dimension.descripcion}"/>
                                                </div>
	                                         </td>
	                                         <td align="left"  style="background: #ffffff ; color: #000000" class="labelobjetivos celda">
	                                         	<div style="width:30%;" class="divCalificacion">
	                                         		<table align="left">		                                         				
                                       					<tr>
	                                       					<td rowspan="2" align="left">
	                                       						<c:out value="${dimension.resultadoCadena1}"/>
	                                       					</td>
	                                       					<td>
																&nbsp;
															</td>
                                       					</tr>
                                       					<tr>
                                       						<td>
                                       							&nbsp;
                                       						</td>
                                       					</tr>
                                   					</table>	                                         		
	                                         	</div>
	                                         	
			                            		<div style="float:left; width: 35%;">
			                            			<table align="center">		                                         				
                                       					<tr>
                                       						<c:choose>
                                       							<c:when test="${dimension.opcionSeleccionado1 == '1'}">
                                       								<td align="center"><input type="radio" value="1" checked="checked" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:when>
                                       							
                                       							<c:when test="${dimension.opcionSeleccionado1 == '2'}">
                                       								<td align="center"><input type="radio" value="1" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" checked="checked" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:when>
                                       							
                                       							<c:when test="${dimension.opcionSeleccionado1 == '3'}">
                                       								<td align="center"><input type="radio" value="1" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" checked="checked" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:when>
                                       							
                                       							<c:when test="${dimension.opcionSeleccionado1 == '4'}">
                                       								<td align="center"><input type="radio" value="1" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" checked="checked" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:when>
                                       							
                                       							<c:when test="${dimension.opcionSeleccionado1 == '5'}">
                                       								<td align="center"><input type="radio" value="1" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" checked="checked" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:when>
                                       							
                                       							<c:otherwise>
                                       								<td align="center"><input type="radio" value="1" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="2" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="3" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="4" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
		                                       						<td align="center"><input type="radio" value="5" name='<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' onclick="calcularSuma(this);"></td>
                                       							</c:otherwise>
                                       						</c:choose>
                                       					</tr>
                                       					<tr>
                                       						<td align="center">1</td>
                                       						<td align="center">2</td>
                                       						<td align="center">3</td>
                                       						<td align="center">4</td>
                                       						<td align="center">5</td>
                                       					</tr>
                                       				</table>
			                            		</div>
			                            		
			                            		<div style="float:left; width: 30%; margin-left: 5px">
		                            				<table align="left">
                                       					<tr>
	                                       					<td rowspan="2">
	                                       						<c:out value="${dimension.resultadoCadena2}"/>
	                                       					</td>
	                                       					<td>
																&nbsp;
															</td>
                                       					</tr>
                                       					<tr>
                                       						<td>
                                       							&nbsp;
                                       						</td>
                                       					</tr>
                                   					</table>
			                            		</div>
	                                         </td>
	                                         
	                                         <c:if test="${pintoPuntajeTotal == 0}">
	                                         	<c:set var="pintoPuntajeTotal" value="1"></c:set>
		                                         <td align="center" style="background: #ffffff ; color: #000000" height="18px" class="celda" rowspan='<c:out value="${numeroPreguntas}"/>' >
		                                         	<div id='<c:out value="div-${dimension.codCabecera}"/>'>
		                                         		<c:out value="${puntajePorDimension}"/>
		                                         	</div>		                                         		                                         	
		                                         </td>
	                                         </c:if>
	                                     </tr>
                                     </c:if>
			                    </c:forEach>				            	        
		                    </c:if>
		                    <tr>
		                    	<th class="lblPuntuacionFinal" style="text-align: left;" colspan="2">
									<b>&nbsp;Puntaje Total &nbsp;&nbsp;</b>
								</th>
		                    	
		                    	<th class="lblPuntuacionFinal" >
									<div id="divPuntajeFinal">
                               			<c:out value="${puntajeTotal}"/>
                               		</div>
								</th>								
		                    </tr>		                                                
            			</table>
                    </td>
                </tr>
                
                <tr>
                	<td colspan="4" style="text-align: left">
                		<div id="ver_cabecera"></div>
                	</td>
                </tr>
</table>
</html:form>

</body>
<script type="text/javascript">
var operacionGlobal;
var cadena = ""; //Concatena idCabecera-idDetalle/ValorSeleccionado
var numeroTotalFilasDetalle = 0;//Para pasarle como parametro al action, para validar si es que se ha seleccionado todos los radioButtons
var cadenaErrores = "";

	<c:if test="${formulario.strESTADO == 'S5'}">	
		deshabilitaPlanAccion();
	</c:if>	


	function calcularSuma(obj){
		var sumaPorDimension = parseInt("0");
		var sumaTotal = parseInt("0");
		var idCabecera = (obj.name).split('-')[0];
		var listaRadioButtons;// = document.getElementsByName(obj.name);
		//CALCULO LA SUMA POR DIMENSION
		//for (var x=0; x < listaRadioButtons.length; x++) {
		//	if (listaRadioButtons[x].checked){
		//		sumaPorDimension = sumaPorDimension + parseInt(listaRadioButtons[x].value);
		//	}
		//}
		
		//document.getElementById('div-' + idCabecera).innerHTML = sumaPorDimension;
		
		//CALCULO LA SUMA TOTAL
		<c:if test="${!empty lstDimensiones}">
			<c:forEach items="${lstDimensiones}" var="dimension">
				//<c:if test="${dimension.tipo == 'C'}">
				//	sumaTotal = sumaTotal + parseInt(document.getElementById('div-' + '<c:out value="${dimension.codCabecera}"/>').innerHTML);
				//</c:if>
				
				<c:if test="${dimension.tipo == 'D'}">
					if('<c:out value="${dimension.codCabecera}"/>' == idCabecera){
						listaRadioButtons = document.getElementsByName('<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>');
						//CALCULO LA SUMA POR DIMENSION
						for (var x=0; x < listaRadioButtons.length; x++) {
							if (listaRadioButtons[x].checked){
								sumaPorDimension = sumaPorDimension + parseInt(listaRadioButtons[x].value);
							}
						}
						
						//sumaTotal = sumaTotal + parseInt(document.getElementById('div-' + '<c:out value="${dimension.codCabecera}"/>').innerHTML);
					}
				</c:if>
			</c:forEach> 
		</c:if>
		
		document.getElementById('div-' + idCabecera).innerHTML = sumaPorDimension;
		
		<c:if test="${!empty lstDimensiones}">
			<c:forEach items="${lstDimensiones}" var="dimension">
				<c:if test="${dimension.tipo == 'C'}">
					sumaTotal = sumaTotal + parseInt(document.getElementById('div-' + '<c:out value="${dimension.codCabecera}"/>').innerHTML);
				</c:if>
			</c:forEach>
		</c:if>
				
		document.getElementById('divPuntajeFinal').innerHTML = sumaTotal;
	}	

	function validarPotencial(tipoOperacion){
		var seleccionaCalificacion = false;
		var descripcionCabecera = "";
		var numeroFilaError = 0;
		var pintoErrorXDimension = false;
		
		<c:if test="${!empty lstDimensiones}">  
			cadena = "";
			cadenaErrores = "";			
			numeroTotalFilasDetalle = 0;
			
        	<c:forEach items="${lstDimensiones}" var="dimension">
        		seleccionaCalificacion = false;
        		
	        	<c:if test="${dimension.tipo == 'C'}">
	        		numeroTotalFilasDetalle = numeroTotalFilasDetalle + <c:out value="${dimension.numeroFilaDetalle}"/>;
	        		descripcionCabecera = '<c:out value="${dimension.descripcion}"/>';
	        		pintoErrorXDimension = false;
	        	</c:if>
	        	
        		<c:if test="${dimension.tipo == 'D'}">
        			var listaRadioButtons = document.getElementsByName('<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>');
        			//alert("listaRadioButtons.length: " + listaRadioButtons.length);
        			for (var i=0; i < listaRadioButtons.length; i++){
       			   		if (listaRadioButtons[i].checked){
       			   			seleccionaCalificacion = true;
       			   			if(cadena != ""){
       			   				cadena = cadena + ";"; 
       			   			}
       			      		cadena = cadena + '<c:out value="${dimension.codCabecera}"/>-<c:out value="${dimension.codDetalle}"/>' + "-" + listaRadioButtons[i].value;
       			      	}
       			   }
					if(seleccionaCalificacion == false && pintoErrorXDimension == false){
						numeroFilaError++;
						if(numeroFilaError != 1){
							cadenaErrores = cadenaErrores + "<br>";
						}						
						
						pintoErrorXDimension = true;						
						cadenaErrores = cadenaErrores + "Debe calificar todas las preguntas de la dimensión " + descripcionCabecera + ".";
					}	
					
        		</c:if>
        	</c:forEach>     	
        </c:if>
		
        if(tipoOperacion == 'g'){
	        grabar();
        }
	}

	function pintarErrores(tipoOperacion){
		if(cadenaErrores != ""){
			var itemsHtml = "";
			itemsHtml = "<table>";
		      	itemsHtml += "<tr>";
		      	
		      	if(tipoOperacion == 'g'){
		      		itemsHtml += "<td colspan='4' class='labelErrorULBlue'>Inconsistencias encontradas :";
		      		itemsHtml += "</td></tr>";
			      	itemsHtml += "<tr>";
			      	itemsHtml += "<td colspan='4' class='labelErrorULBlue'>" + cadenaErrores ;
			      	itemsHtml += "</td></tr>";
		      	}
		      	else if(tipoOperacion == 'e'){
		      		itemsHtml += "<td colspan='4' class='labelErrorUL'>Inconsistencias encontradas :";
		      		itemsHtml += "</td></tr>";
			      	itemsHtml += "<tr>";
			      	itemsHtml += "<td colspan='4' class='labelErrorUL'>" + cadenaErrores ;
			      	itemsHtml += "</td></tr>";
		      	}
		      			      	
	      	itemsHtml += "</table>";
	      	document.getElementById('ver_cabecera').innerHTML = itemsHtml;
		}
		else{
			document.getElementById('ver_cabecera').innerHTML = "";			
		}
	}
	
    function grabar(){
		operacionGlobal="g"; 
		operacionxAjax(operacionGlobal, "g", '<%=request.getContextPath()%>');
    }

    function enviar(){
    	var mensaje = confirm("Después de evaluar, no se podrá realizar más \n modificaciones a la Evaluación de Potencial \n ¿Está seguro de continuar?");
        if(mensaje){
	    	validarPotencial('e');
	    	//alert("cadenaErrores |" + cadenaErrores + "|");
	    	if(cadenaErrores != ""){
	    		//PRIMERO ARMO EL MENSAJE DEL ENCABEZADO
	    		itemsHtml = "<table>";
	        	itemsHtml += "<tr>";
	          	itemsHtml += "<td colspan='4' style='text-align: left'>";
	          	itemsHtml +="<font color='red' style='font-weight: bold;font-family: Arial;font-size: 13px'>NO SE PUDO ENVIAR LA EVALUACIÓN</font>";
	          	itemsHtml += "</td></tr>";
	  	        itemsHtml += "</table>";
	  	        document.getElementById('ver_mensaje').innerHTML = itemsHtml;
	          	
	    		pintarErrores("e");
	    	}
	    	else{//alert("envio");
	    		operacionGlobal="g"; 
	    		operacionxAjax(operacionGlobal, "e", '<%=request.getContextPath()%>');
	    	}	
        }
 	}
    
 // -----------------------------------------------------------------------------------------------
    function operacionxAjax(operacion, subOperacion, ruta){
    	
      url=ruta + '/evaluacionPotencial.do?method=operacionesPotencial&operacion='+ operacion+'&operacion2=' + subOperacion ;
      url = url+'&ms='+(new Date()).getTime();
      ajax0 = new Ajax.Request(url,{
          asynchronous: false,
          method: 'post',
          parameters: {
        	  idEvaluado: document.getElementById("idEvaluado").value,
        	  cadenaValores: cadena,
        	  periodo: document.getElementById("periodo").value,
        	  nombreEvaluado: '<c:out value="${formulario.strNom_Empleado}"/>' + " " + '<c:out value="${formulario.strApellido_Empleado}" />'
        	  },
          onSuccess: function(transport, json) {
        	     if(json.executeError){
        	      	alert(json.executeError);
        	      }
        	      else{
        	    	  //alert("operacionGlobal:" + json.prueba);
        	    	  itemsHtml = "<table>";
            	      itemsHtml += "<tr>";
            	      itemsHtml += "<td colspan='4' style='text-align: left'>";
            	      //if (subOperacion=="g") {
            	    	  itemsHtml +="<font color='#1F497D' style='font-weight: bold;font-family: Arial;font-size: 13px'>" + json.mensaje + "</font>";
					  //}else if (subOperacion=="e") {
					//	  	alert("e");
					//		 itemsHtml +="<font color='#1F497D' style='font-weight: bold;font-family: Arial;font-size: 13px'>" + json.mensaje + "</font>";
					  //}
            	      	
            	      itemsHtml += "</td></tr>";
            	      itemsHtml += "</table>";
            	      document.getElementById('ver_mensaje').innerHTML = itemsHtml;
            	      
            	      if (subOperacion=="e") {
	            	      if(json.resultado == "1"){//TENGO QUE OCULTAR LOS BOTONES	            	    	  
	            	    	  document.getElementById("trDivGrabar").style.display = "none";
	            	    	  document.getElementById("trDivEnviar").style.display = "none";
	            	    	  //TENGO QUE DESHABILITAR TODO EL FORMULARIO
	            				deshabilitaPlanAccion();
	            	      }
            	      }
            	      
					  pintarErrores(operacion);
           	    }
       	      } //Fin de la Funcion
      });  
    }

//---------------------------------------------------------------------------------
    
    function retornarHeight(h){
        var posicion_y;
        posicion_y=(screen.height/2)-(h/2);
        return posicion_y;
    }

    function retornarWidth(w){
        var posicion_x;
        posicion_x=(screen.width/2)-(w/2);
        return posicion_x;
    }
 
    function cerrar(){
        window.close();
    }
    
    function imprimirEvaluacionPotencial(){
        var url = "<%=request.getContextPath()%>/evaluacionPotencial.do?method=imprimirPotencial&periodo=" +  <c:out value="${formulario.strPERIODO}"/> + "&idEmpleado=" + document.getElementById("idEvaluado").value;              
        var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=800, height=800, top="+retornarHeight(800)+", left="+retornarWidth(800);
        window.open(url,"",opciones);
    }
</script>

</html>
<%}catch(Exception e){e.printStackTrace();} %>

